/*
 * @lc app=leetcode.cn id=83 lang=javascript
 *
 * [83] 删除排序链表中的重复元素
 */

// @lc code=start
/**
 * Definition for singly-linked list.
 * function ListNode(val, next) {
 *     this.val = (val===undefined ? 0 : val)
 *     this.next = (next===undefined ? null : next)
 * }
 */
/**
 * @param {ListNode} head
 * @return {ListNode}
 */
// var deleteDuplicates = function(head) {
//   if(!head) return null;
//   let cur = head;
//   while(cur.next) {
//     if( cur.val === cur.next.val) {
//       cur.next = cur.next.next
//     } else {
//       cur = cur.next;
//     }
//   }
//   return head;
// };

/**
 * 复习 2021-08-04
 */
var deleteDuplicates = function(head) {
  if(!head) return head;
  let p = head;
  while(p.next) {
    let next = p.next;
    if(p.val == next.val){
      p.next = next.next;
    } else {
      p = p.next
    }
  }
  return head;
}


// @lc code=end

